package com.kcs.fxmargin.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class CommonDao {
	
	public int getRowVersion(Connection conn, PreparedStatement pstm, ResultSet rs, String tableName, String id) throws Exception{
		StringBuffer sql 		= new StringBuffer();
		int rowVersion	= 0;
		
		sql.append(" select row_version ");
		sql.append(" from " + tableName + " ");
		sql.append(" where id = ?");
		
		System.out.println("SQL -> " + sql.toString());
		
		pstm = conn.prepareStatement(sql.toString());
		pstm.setString(1, id);
		
		rs = pstm.executeQuery();
		
		while(rs.next()){
			rowVersion = rs.getInt("row_version");
		}
		
		System.out.println("RowVersion = " + rowVersion);
		
		return rowVersion;
	}
}
